import java.io.*;

public class FileTest1 {

    public static void main(String[] args) {

        File file = new File("./demo.json");
        if (!file.exists()) {

            if (!file.getParentFile().exists()) {
                file.getParentFile().mkdir();
            }
            try {
                file.createNewFile();
            } catch (IOException e) {
                e.printStackTrace();
            }

        }
        System.out.println("文件名:" + file.getName());

        System.out.println("文件完整路径:" + file.getAbsolutePath());

        BufferedWriter bufferedWriter = null;

        try {

            FileOutputStream out = new FileOutputStream(file);
            bufferedWriter = new BufferedWriter(new OutputStreamWriter(out));

            bufferedWriter.write("...json...");
            bufferedWriter.flush();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
